package com.atguigu.mybatis.lamda;

import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * Created by Smexy on 2022/11/9
 */
public class StreamDemo
{
    public static void main(String[] args) {

        //获取Stream
        Stream<Integer> stream = Stream.of(1, 2, 3);

        List<Integer> list = Arrays.asList(1, 2, 3);
        Stream<Integer> stream1 = list.stream();

        int [] nums = {1,2,3};

        IntStream stream2 = Arrays.stream(nums);

        //运算  每个元素 + 1，返回奇数
        List<Integer> result = stream1
            .map(num -> num + 1)
            .filter(num -> num % 2 == 1)
            .collect(Collectors.toList());

        System.out.println(result);
    }
}
